package BehavioralPattern.Visitor.visitor;

import BehavioralPattern.Visitor.element.CommonEmployee;
import BehavioralPattern.Visitor.element.Employee;
import BehavioralPattern.Visitor.element.Manager;

/**
 * @Classname : ConcreteShowVisitor
 * @Description : 具体访问者——展示报表
 * @Author : chentianyu
 * @Date 2023/3/12 10:45
 */


public class ConcreteShowVisitor implements ShowVisitor {
    private String info = "";

    @Override
    public void visit(CommonEmployee employee) {
        this.info += getBasicInfo(employee) + "工作：" + employee.getJob() + "\t\n";
    }

    @Override
    public void visit(Manager manager) {
        this.info += getBasicInfo(manager) + "业绩：" + manager.getPerformance() + "\t\n";
    }

    @Override
    public void report() {
        System.out.print(this.info);
    }

    // 组装基本信息
    private String getBasicInfo(Employee employee) {
        String info = "姓名：" + employee.getName() + "\t";
        info += "性别：" + (employee.getSex() == Employee.MALE  ? "男" : "女") + "\t";
        info += "薪资：" + employee.getSalary() + "\t";
        return info;
    }

}
